package com.yanqu.road.server.cmd.activity.huashigang;

import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.huashigang.HuaShiGangProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.cross.battle.HuaShiGangMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;

/**
 * @Author wpj
 * @Date 2020/10/4
 */

@Cmd(code = CrossProtocol.C2_GET_HUA_SHI_GANG_USER_DATA, desc = "获取花石纲用户数据")
public class CrossGetHuaShiGangUserDataCmd extends CrossCommand {

    int activityId;
    long userId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        HuaShiGangProto.GetHuaShiGangUserDataReqMsg msg = HuaShiGangProto.GetHuaShiGangUserDataReqMsg.parseFrom(packet.getBytes());
        activityId = msg.getActivityId();
        userId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
//        HuaShiGangUserData huaShiGangUserData =  HuaShiGangMgr.getHuaShiGangUserData(activityId, serverId, userId);
//        HuaShiGangProto.GetHuaShiGangUserDataRespMsg.Builder builder = HuaShiGangProto.GetHuaShiGangUserDataRespMsg.newBuilder();
//
//        if (huaShiGangUserData == null) {
//            builder.setRet(GameErrorCode.E_ACTIVITY_NO_FOUND);
//        } else {
//            builder.setRet(0);
//            builder.setX(huaShiGangUserData.getX());
//            builder.setY(huaShiGangUserData.getY());
//            builder.setIsFinish(huaShiGangUserData.isFinish());
//            builder.setMonsterId(huaShiGangUserData.getMonsterId());
//            builder.addAllPatronsId(huaShiGangUserData.getRandomPatronsId());
//            if (huaShiGangUserData.getPatronsMap().size() > 0) {
//                for (HuaShiGangPatrons patrons : huaShiGangUserData.getPatronsMap().values()) {
//                    HuaShiGangProto.HuaShiGangPatronsAdditionEntity.Builder entity = HuaShiGangProto.HuaShiGangPatronsAdditionEntity.newBuilder();
//                    entity.setPatronsId(patrons.getPatId());
//                    entity.setAddition(patrons.getAddition());
//                    entity.setBossAttackTimes(patrons.getBat());
//                    entity.setNormalAttackTimes(patrons.getNat());
//                    builder.addAddition(entity);
//                }
//            }
//            HuaShiGangActivity activity = HuaShiGangMgr.getHuaShiGangActivity(activityId);
//            List<HuaShiGangStrongPoint> pointList = activity.getUserNextPoints(huaShiGangUserData.getY());
//            builder.addAllRoute(HuaShiGangPb.getHuaShiGangStrongPointPbList(pointList));
//        }

        MessageHelper.sendPacket(serverId, userId, YanQuMessageUtils.buildMessage(ClientProtocol.U_GET_HUA_SHI_GANG_USER_DATA, HuaShiGangMgr.getHuaShiUserDataGangRespMsg(activityId, serverId, userId)));
    }

    @Override
    public void sendData() {

    }
}
